home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / AmigaUtil / HookUtil.mod < prev    next >
Text File  |  1994-08-08  |  2KB  |  72 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: HookUtil.mod $
  4.   Description:
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 16:11:09 $
  10.  
  11.   Copyright © 1994, Frank Copeland.
  12.   This file is part of the Oberon-A Library.
  13.   See Oberon-A.doc for conditions of use and distribution.
  14.  
  15. *************************************************************************)
  16.  
  17. MODULE HookUtil;
  18.  
  19. (*
  20. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  21. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  22. ** $V- OvflChk       $Z- ZeroVars
  23. *)
  24.  
  25. IMPORT E := Exec, U := Utility, SYS := SYSTEM;
  26.  
  27. (*------------------------------------*)
  28. (*
  29.   This procedure is intended to be installed in the entry field of a
  30.   U.Hook record.  Its purpose is to push the parameters passed to it
  31.   onto the stack and call the procedure installed in the subEntry field.
  32.  
  33.   The parameters are:
  34.  
  35.     hook    : U.HookPtr; (* passed in the A0 register *)
  36.     object  : E.APTR;    (* passed in the A2 register *)
  37.     message : E.APTR;    (* passed in the A1 register *)
  38.  
  39.   Stack checking should be turned off ($S-) in all procedures installed
  40.   in Hooks, as they are likely to be running in a non-Oberon context.
  41. *)
  42.  
  43. (* $r- Suppress RETURN check *)
  44. PROCEDURE HookEntry* () : E.APTR;
  45.  
  46. BEGIN (* HookEntry *)
  47.   SYS.INLINE (
  48.     2F08H,                       (* MOVE.L A0, -(A7)      *)
  49.     2F0AH,                       (* MOVE.L A2, -(A7)      *)
  50.     2F09H,                       (* MOVE.L A1, -(A7)      *)
  51.     2068H, 000CH,                (* MOVE.L  000C(A0), A0  *)
  52.     4E90H                        (* JSR    (A0)           *)
  53.     )                            (* RTS                   *)
  54.   (*
  55.     No RETURN is required, result is already in D0.
  56.     Compiler automatically generates RTS.
  57.     The procedure in subEntry will clean up the parameters on the stack.
  58.   *)
  59. END HookEntry;
  60.  
  61. (*------------------------------------*)
  62. PROCEDURE InitHook *
  63.   (VAR hook : U.Hook; subEntry : U.HookFunc; data : E.APTR);
  64.  
  65. BEGIN (* InitHook *)
  66.   hook.entry := HookEntry;
  67.   hook.subEntry := subEntry;
  68.   hook.data := data;
  69. END InitHook;
  70.  
  71. END HookUtil.
  72.